import { request } from '../../request/index'
import { login } from '../../utils/asyncWX'
Page({
  async getUserInfo(e) {
    const { encryptedData, iv, rawData, signature } = e.detail
    const { code } = await login()
    const { token } = await request({
      url: '/users/wxlogin',
      method: 'POST',
      data: {
        encryptedData,
        iv,
        rawData,
        signature,
        code
      }
    })
    // 不是企业id拿不到token
    wx.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo')
    wx.navigateBack({
      delta: 1
    }) 
  }
})